/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#include "ShortcutManager.h"

namespace PQBuilder
{
	Shortcut::Shortcut(OpType op,int numInput,...)
	{
		Op=op;
		int m = 0;
		va_list list;
		va_start(list, numInput);
		for(int i= 0; i< numInput; i++ ){
			int t = va_arg(list, int);
			Input.push_back(t);
		}
		va_end(list);
	}

	ShortcutManager::ShortcutManager(std::string name)
	{
		_name=name;
	}

	ShortcutManager::ShortcutManager()
	{
		_name="Default";
		//if shortcut file not exist then
		loadDefault();
		sortOps();
	}
	
	void ShortcutManager::loadDefault()
	{
		for(int i=0;i<SHORTCUT_TYPE_COUNT;i++){
			_shortcuts[i].clear();
		}
		
		Shortcut* p=0;
		//Select , delete
		p=new Shortcut(OP_SELECT,1,MOUSE_BUTTON_LEFT);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);
		p=new Shortcut(OP_DELETE,1,KEY_CODE_Delete);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);

		//Scene Edit Mode change
		p=new Shortcut(OP_MODE_SELECT,1,KEY_CODE_Q);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);

		p=new Shortcut(OP_MODE_TRANSLATE,1,KEY_CODE_T);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);
		p=new Shortcut(OP_MODE_ROTATE,1,KEY_CODE_Y);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);
		p=new Shortcut(OP_MODE_SCALE,1,KEY_CODE_U);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);

		//Scene Camera manipulate
		p=new Shortcut( OP_CAMERA_ROTATE,1,MOUSE_BUTTON_RIGHT);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);
		p=new Shortcut( OP_CAMERA_ROTATE_OBJECT,2,MOUSE_BUTTON_RIGHT,KEY_CODE_ALT);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);

		p=new Shortcut( OP_CAMERA_PAN,2,MOUSE_BUTTON_RIGHT,KEY_CODE_CTRL);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);

		p=new Shortcut( OP_CAMERA_FORWARD,1,KEY_CODE_W);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);
		p=new Shortcut( OP_CAMERA_BACKWARD,1,KEY_CODE_S);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);
		p=new Shortcut( OP_CAMERA_LEFTWARD,1,KEY_CODE_A);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);
		p=new Shortcut( OP_CAMERA_RIGHTWARD,1,KEY_CODE_D);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);

		p=new Shortcut( OP_CAMERA_UPWARD,1,KEY_CODE_E);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);
		p=new Shortcut( OP_CAMERA_DOWNWARD,1,KEY_CODE_R);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);

		//Start game engine
		p=new Shortcut(OP_PLAY,1,KEY_CODE_P);
		_shortcuts[SHORTCUT_TYPE_GENERAL].push_back(p);

		//Add General shortcuts just above this line......

		//Frame GameObject
		p=new Shortcut(OP_FRAME_OBJECT,1,KEY_CODE_F);
		_shortcuts[SHORTCUT_TYPE_OBJECT].push_back(p);

		//Add Manipulate Object shortcuts just above this line....
		//Deform Terrain Height
		p=new Shortcut(OP_TERRAIN_EDIT_HEIGHT_MODE,1,KEY_CODE_H);
		_shortcuts[SHORTCUT_TYPE_TERRAIN].push_back(p);

		//Paint Terrain Layer
		p=new Shortcut(OP_TERRAIN_BLEND_LAYER_MODE,1,KEY_CODE_B);
		_shortcuts[SHORTCUT_TYPE_TERRAIN].push_back(p);

		//Add Manipulate Terrain shortcuts just above this line....
	}

	void ShortcutManager::save()
	{
	}

}
